package com.zxy.supplier_system.server.repository

import com.zxy.supplier_system.server.entity.CompositeGoods
import com.zxy.supplier_system.server.entity.Goods
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository

@Repository
interface CompositeGoodsRepository : JpaRepository<CompositeGoods, String> {
    
    fun deleteBySourceGoods(goods: Goods)
    
    @Query("SELECT c FROM CompositeGoods c WHERE c.sourceGoods.id = :goodsId")
    fun findBySourceGoodsId(@Param("goodsId") goodsId: Int): List<CompositeGoods>
}